﻿<UserControl x:Class="TreeBuilder.TriangleLink"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ctrl="clr-namespace:Elderos.Controls;assembly=Elderos.Controls" 
             xmlns:local="clr-namespace:TreeBuilder"
             xmlns:cp="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <local:ThicknessConverter x:Key="ThicknessConverter"/>
    </UserControl.Resources>
    <UserControl.ContextMenu>
        <ContextMenu Name="Menu" Opened="Menu_OnOpened" Closed="Menu_OnClosed">
            <MenuItem>
                <MenuItem.Header>
                    <cp:ColorPicker Name="ColorPicker" VerticalContentAlignment="Stretch"/>
                </MenuItem.Header>
            </MenuItem>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="4*"/>
                </Grid.ColumnDefinitions>
                <Label Content="Thickness:"/>
                <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" 
                    Grid.Column="1"
                    MinWidth="30"
                    Text="{Binding ElementName=Line,Path=StrokeThickness, Mode=TwoWay,Converter={StaticResource ThicknessConverter}}"
                    Validate="ValidateDouble" FinalValidation="ValidateThickness" DefaultValue="1"           
                        />
            </Grid>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="4*"/>
                </Grid.ColumnDefinitions>
                <Label Content="Dashes:"/>
                <ctrl:ValidatableTextBox Style="{StaticResource ValidatableBoxStyle}" Grid.Column="1"
                        Text="{Binding ElementName=Line,Path=StrokeDashArray, Mode=TwoWay}"
                                         Validate="ValidateDoubleCollection" FinalValidation="ParseDoubleCollection" DefaultValue=""
                        MinWidth="30"
                        />
            </Grid>
            <MenuItem Name="DeleteMenuItem" Header="Delete" Click="DeleteMenuItem_Click">
                <MenuItem.Icon>
                    <Image Source="pack://application:,,,/Icons/delete.png"></Image>
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
    </UserControl.ContextMenu>
    <Polyline Name="Line" Loaded="Line_OnLoaded" MouseLeftButtonUp="Line_OnMouseLeftButtonUp">
        <Polyline.Stroke>
            <SolidColorBrush Color="{Binding ElementName=ColorPicker,Path=SelectedColor,Mode=TwoWay}"/>
        </Polyline.Stroke>
        <Polyline.Points>
            <Point X="50" Y="0"/>
            <Point X="0" Y="100"/>
            <Point X="100" Y="100"/>
            <Point X="50" Y="0"/>
        </Polyline.Points>
    </Polyline>
</UserControl>
